package com.aw.guiguzi.bean

import com.aw.baselib.base.AwResponseBean
import com.aw.baselib.util.AwDataUtil
import com.aw.baselib.util.AwDateUtil
import java.io.Serializable

class UserInfoBean : AwResponseBean<Any?>(), Serializable {
    var id: String? = null
        private set
    var username: String? = null
    var nickname: String? = null
    var remark: String? = null
    var deptId: String? = null
    var deptName: String? = null
    var email: String? = null
    var mobile: String? = null
    var sex: String? = null
    var avatar: String? = null
    var status: String? = null
    var loginIp: String? = null
    var loginDate: String? = null
    var createTime: String? = null
    var password: String? = null
    var postIds: List<Any>? = null
    var roleIds: List<Any>? = null
    var roles: List<RolesBean>? = null
    var posts: List<PostsBean>? = null
    override fun getItemName(): String {
        return nickname!!
    }

    override fun getItemId(): String {
        return id!!
    }

    val isEnable: Boolean
        get() = !AwDataUtil.isEmpty(status) && status == "0"

    fun formatLoginTime(): String {
        return if (AwDataUtil.isEmpty(loginDate)) {
            ""
        } else AwDateUtil.formatUnixTime(loginDate)
    }

    override fun setItemId(id: String) {
        this.id = id
    }

    override fun toString(): String {
        return "UserListItemBean{" +
                "id='" + id + '\'' +
                ", username='" + username + '\'' +
                ", nickname='" + nickname + '\'' +
                ", remark='" + remark + '\'' +
                ", deptId='" + deptId + '\'' +
                ", deptName='" + deptName + '\'' +
                ", postIds='" + postIds + '\'' +
                ", email='" + email + '\'' +
                ", mobile='" + mobile + '\'' +
                ", sex='" + sex + '\'' +
                ", avatar='" + avatar + '\'' +
                ", status='" + status + '\'' +
                ", loginIp='" + loginIp + '\'' +
                ", loginDate='" + loginDate + '\'' +
                ", createTime='" + createTime + '\'' +
                ", password='" + password + '\'' +
                '}'
    }

    class DeptBean {
        /**
         * id : 103
         * name : 研发部门
         * parentId : 101
         */
        var id = 0
        var name: String? = null
        var parentId: String? = null
    }

    class RolesBean {
        /**
         * id : 1
         * name : 超级管理员
         */
        var id: String? = null
        var name: String? = null
    }

    class PostsBean {
        /**
         * id : 1
         * name : 董事长
         */
        var id = 0
        var name: String? = null
    }
}